using System.Net;
using System.Text;

namespace PropertyManagementSystemAPI.Common.WeChatHelper
{
    public class WeChat_Config
    {
        //微信公众平台APPID
        public static string wx_appid = "";
        //微信公众平台秘钥
        public static string wx_select = "";

        //用户授权接口
        public static string code_url = "https://open.weixin.qq.com/connect/oauth2/authorize?";

        //授权成功后重定向地址
        public static string redirect_url = "用户授权后回调地址";

        //获取token接口
        public static string token_url = "https://api.weixin.qq.com/sns/jscode2session?";

        //获取个人信息接口
        public static string userinfo_url = "https://api.weixin.qq.com/sns/userinfo?";

        //获取接口调用凭证接口
        public static string getAccessToken_url = "https://api.weixin.qq.com/cgi-bin/token?";

        public static string HttpGet(string url, Encoding encode = null)
        {
            string result;
            try
            {
                var webClient = new WebClient { Encoding = Encoding.UTF8 };

                if (encode != null)
                    webClient.Encoding = encode;

                result = webClient.DownloadString(url);
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return result;
        }
    }



}
